﻿using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Abp.Modules;
using Abp.Reflection.Extensions;
using FwProject.Configuration;
using Abp.AspNetCore.Configuration;
using Abp.Runtime.Caching.Redis;
using System.Net.Http;
using System.Threading;
using Abp.AspNetCore.SignalR;

namespace FwProject.Web.Startup
{
    [DependsOn(typeof(FwProjectShopCoreWebCoreModule),
          typeof(AbpRedisCacheModule),
          typeof(AbpAspNetCoreSignalRModule))]
    public class FwProjectWebMvcModule : AbpModule
    {
        private readonly IHostingEnvironment _env;
        private readonly IConfigurationRoot _appConfiguration;

        public FwProjectWebMvcModule(IHostingEnvironment env)
        {
            _env = env;
            _appConfiguration = env.GetAppConfiguration();
        }

        public override void PreInitialize()
        {

            Configuration.Caching.UseRedis(options => {
                options.ConnectionString = _appConfiguration["Abp:RedisCache:ConnectionString"];
                options.DatabaseId = _appConfiguration.GetValue<int>("Abp:RedisCache:DatabaseId");
            });

            Configuration.Navigation.Providers.Add<FwProjectNavigationProvider>();
           
        }

        public override void Initialize()
        {
           
            IocManager.RegisterAssemblyByConvention(typeof(FwProjectWebMvcModule).GetAssembly());
         
        }
    }
}
